package algorithm;

import java.util.Arrays;

/**
 * @author rongkai
 * @description:
 * @date 2021/3/27
 */
public class Solution192 {

    public static void main(String[] args) {
        int[][] nums = {{1,5,1},{1,6,9},{1,7,7}};
        int solution = solution(nums);
        System.out.println(solution);
    }

    public static int solution(int[][] nums){
        if (null == nums || nums.length == 0){
            return 0;
        }
        int x = nums.length;
        int y = nums[0].length;
        int dp[][] = new int[x+1][y+1];
        for(int i = x-1;i>=0;i--){
            for(int j = y-1;j>=0;j--){
                dp[i][j] = min(dp,i,j)+nums[i][j];
            }
            System.out.println(1);
        }
        return dp[0][0];
    }

    public static int min(int[][] dp,int i,int j){
        if (dp[i+1][j] == 0){
            return dp[i][j+1];
        }else if (dp[i][j+1] == 0){
            return dp[i+1][j];
        }else{
            return Math.min(dp[i+1][j],dp[i][j+1]);
        }
    }
}
